// components/shift-set/shift-set.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    date:String,
    addColor:String,
    updateColor:String,
    shift_type:String,
    overTime:String,
  },

  /**
   * 组件的初始数据
   */
  data: {
    array: ['早班', '中班', '晚班', '休息'],
    // objectArray: [
    //   {
    //     id: 0,
    //     name: '早班'
    //   },
    //   {
    //     id: 1,
    //     name: '中班'
    //   },
    //   {
    //     id: 2,
    //     name: '晚班'
    //   },
    //   {
    //     id: 3,
    //     name: '休息'
    //   }
    // ],
    index: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    bindPickerChange: function(e) {
      const i = e.detail.value
      const array = this.data.array
      this.setData({
        index: e.detail.value,
        shift_type:array[i]
      })
    },

    overtimeAdd: function(e){
      const ot = e.detail.value      
      this.setData({
        overTime: ot
      })
    },

    AddShift: function(event){
      let shift_type = this.properties.shift_type
      let date = this.properties.date
      let overtime = this.properties.overTime
      this.triggerEvent('Add',
      {
        shift_type: shift_type,
        date: date,
        overtime: overtime,
      },{})
      
    },

    UpdateShift: function(event) {
      let shift_type = this.properties.shift_type
      let date = this.properties.date
      let overtime = this.properties.overTime
      this.triggerEvent('Update',
      {
        shift_type: shift_type,
        date: date,
        overtime: overtime
      },{})
    }
  },

  

})
